package ve.basura.entrada.core;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SWTCore {
	
	public static Shell getShell(Display display) {
		return  new Shell(display, SWT.CLOSE | SWT.MIN | SWT.MAX);
	}
	
	public static void openShell(Shell shell, Display display) {
		
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		
	}

	//realocate splash screen location
	public static void setLocation(Shell shell, Display display){
		Rectangle shellRect = shell.getBounds();
		Rectangle displayRect = display.getBounds();
		int x = (displayRect.width - shellRect.width) / 2;
		int y = (displayRect.height - shellRect.height) / 2;
		shell.setLocation(x, y);
	}

	
}
